layui.use(['jquery','element'],function (){
    var $= layui.jquery;
    var element = layui.element();
    $.ajax({
        type:"GET",
        url : "/admin/Tree/Menu",
        dataType:"json",
        success : function(res){
            for (var re of res.data) {
                var content='<li class="layui-nav-item">';
                if (re.childrens!=""){
                    content +=  '   <a href="javascript:;"><i class="iconfont">'+re.icon+'</i>'+re.menuname+'</a>';
                    content +=' <dl class="layui-nav-child">';
                    for(var c of re.childrens) {
                        content += '<dd>';
                        content += ' <a href="javascript:;" data-url=' + c.curl + ' data-id='+c.cid+' data-text=' + c.cname + '><span class="l-line"></span>' + c.cname + '</a>'
                        content += '</dd>';
                    }
                    content += '</dl>'
                }else {
                    content +='<a href="javascript:;" data-url='+re.path+' data-id='+re.id+' data-text='+re.menuname+'><i class="iconfont">'+re.icon+'</i>'+re.menuname+'</a>'
                }
                content +=   '</li>';
                $(".layui-nav-tree").append(content);
                element.init();
            }
        }

    })
})